import { useEffect, useState } from 'react'
// import { useHistory } from 'react-router'
let timerId
export default function NotFound() {
  // const history = useHistory()
  const [state, setState] = useState(5)
  useEffect(() => {
    timerId = setInterval(() => {
      setState(state - 1) //异步的
    }, 1000)
    return () => {
      clearInterval(timerId)
    }
  })
  useEffect(() => {
    if (state <= 0) {
      // history.push('/home')
      clearInterval(timerId)
    }
  }, [state])
  return <div>{`你访问的页面已丢失,${state}秒之后自动跳转到登录页`}</div>
}
